<html>
<head><meta charset="utf-8"><title>Documentation outputs · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Documentation.20outputs.html">Documentation outputs</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="219653596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Documentation%20outputs/near/219653596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Documentation.20outputs.html#219653596">(Dec 11 2020 at 19:52)</a>:</h4>
<p>This is kind of a complicated question but I'll give it my best shot. <span class="user-mention" data-user-id="265377">@Will Crichton</span> is writing a tool to show where a function is used, in particular across crates and including <code>examples</code>: <a href="https://github.com/willcrichton/example-analyzer">https://github.com/willcrichton/example-analyzer</a>. It's based on a fork of rustdoc and I'm hoping to upstream it into rustdoc directly at some point. The issue is that it introduces a reverse dependency between documentation builds of the example and documentation builds of the main crate. It looks something like this (simplified):</p>
<div class="codehilite" data-code-language="Bash"><pre><span></span><code>$ rustc --profile check src/lib.rs
$ example-analyzer examples/a/main.rs --extern <span class="nv">my_crate</span><span class="o">=</span>/path/to/libmy_crate.rlib --output call-locations.json
$ rustdoc src/lib.rs --call-locations /path/to/call-locations.json
</code></pre></div>
<p>(JSON is temporary, if <code>example-analyzer</code> and <code>rustdoc</code> use the same toolchain it can serialize DefIds in an .rlib directly, although I need to work out how that interacts with rustc_metadata.)</p>
<p>Is this something that makes sense in cargo's build model? I don't see any cyclic dependencies here, but I'm sure this is definitely not the order things happen in currently. If it's not, would you be interesting in adding it, assuming this gets upstreamed to rustdoc?</p>



<a name="219653805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Documentation%20outputs/near/219653805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Documentation.20outputs.html#219653805">(Dec 11 2020 at 19:54)</a>:</h4>
<p>this would also be useful for making <a href="https://github.com/robinmoussu/cargo-callgraph">https://github.com/robinmoussu/cargo-callgraph</a> work across crates (cc <span class="user-mention" data-user-id="281841">@Robin Moussu</span> )</p>



<a name="219660187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Documentation%20outputs/near/219660187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robin Moussu <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Documentation.20outputs.html#219660187">(Dec 11 2020 at 20:48)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> thanks for making me aware of example-analyzer. Something that would help me a lot (and I think <code>example-analyzer</code> would too) would be to have a generic <code>cargo-analyze</code> where you could chose if you want to run <code>rustdoc</code>, <code>callgraph</code> or <code>example-analyzer</code> (instead of using <code>RUSTDOC=xxx cargo doc</code> or <code>cargo +custom-rustdoc doc</code>).</p>
<p><span class="user-mention" data-user-id="265377">@Will Crichton</span> I just took a short glimpse at the source code, but I don’t think that you can detect indirect call (like through <code>Fn()</code> trait call). In cargo-callgraph (not yet released publicly, I think my v0.1 will be available next week), I should be able to do it. At the same time, I’m not sure it’s needed if the goal is to find all examples where a given function is used. I think that both of our project have a lot in common, and exchanging a bit is probably going to be very fruitful for both!</p>



<a name="219660459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Documentation%20outputs/near/219660459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robin Moussu <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Documentation.20outputs.html#219660459">(Dec 11 2020 at 20:51)</a>:</h4>
<p>In case you are interested to know what <code>cargo-callgraph</code> does, I think this posts il the best (I need to write a presentation in my Readme): <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Extract.20callgraph.20of.20a.20crate/near/219027496">https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Extract.20callgraph.20of.20a.20crate/near/219027496</a></p>



<a name="230724403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Documentation%20outputs/near/230724403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Documentation.20outputs.html#230724403">(Mar 17 2021 at 16:38)</a>:</h4>
<blockquote>
<p>@Joshua Nelson thanks for making me aware of example-analyzer. Something that would help me a lot (and I think example-analyzer would too) would be to have a generic cargo-analyze where you could chose if you want to run rustdoc, callgraph or example-analyzer (instead of using RUSTDOC=xxx cargo doc or cargo +custom-rustdoc doc).</p>
</blockquote>
<p><span class="user-mention" data-user-id="281841">@Robin Moussu</span> I think this is RUSTC_WORKSPACE_WRAPPER <a href="https://github.com/rust-lang/cargo/issues/8143">https://github.com/rust-lang/cargo/issues/8143</a></p>



<a name="230733017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Documentation%20outputs/near/230733017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robin Moussu <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Documentation.20outputs.html#230733017">(Mar 17 2021 at 17:30)</a>:</h4>
<p>I will take a look. Thanks.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>